
const state = {
    basicFormData: {
        case_type: '1',
        case_no: '',
        case_name: '',
        case_desc: '',
        case_paper: '',
        case_police: [
            { id: 1, name: '', no: '', tel: '' },
            { id: 2, name: '', no: '', tel: '' }
        ]
    },
    elementFormData: {
        persons: [
            { id: 1, name: '', cardType: '1', cardNo: '', other: [] }
        ]
    },
    clueFormData: {
        desc: '',
        paper: ''
    },
}

const mutations = {
    SET_BASIC_FORM_DATA: (state, data) => {
        state.basicFormData = Object.assign({}, state.basicFormData, data)
    },
    SET_ELEMENT_FORM_DATA: (state, data) => {
        state.elementFormData = Object.assign({}, state.elementFormData, data)
    },
    SET_CLUE_FORM_DATA: (state, data) => {
        state.clueFormData = Object.assign({}, state.clueFormData, data)
    }
}

const actions = {
    setBasicFormData({ commit }, data) {
        commit('SET_BASIC_FORM_DATA', data)
    },
    setElementFormData({ commit }, data) {
        commit('SET_ELEMENT_FORM_DATA', data)
    },
    setClueFormData({ commit }, data) {
        commit('SET_CLUE_FORM_DATA', data)
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}
